<template>
  <view>
		<u-cell-group>
		    <u-cell
              v-for="(item,index) in recordList"
             :key="index" 
             :title="item.title"
             :label="item.position"
             :isLink="true" 
             :value="item.time"
             @click="itemClick(item)"
            >
            </u-cell>
	    </u-cell-group>
	</view>
</template>

<script>
export default {
    onLoad() {
        let that = this;
        let id;
        uni.getStorage({
            key:'studentId',
            success: (res) => {
                        wx.request({
				url: 'http://localhost:8123/record/listone', //仅为示例，并非真实的接口地址
				data: {
					student: res.data,
				},
				header: {
					'content-type': 'application/json' // 默认值
				},
				success:(res => {
					//console.log(res.data.data);
                    const list = res.data.data;
                    for (let i = 0; i < list.length; i++) {
                        list[i].value = JSON.parse(list[i].value)
                        that.recordList.push({title: '每日健康打卡', position: list[i].value[0].val, time:list[i].datetime})
                    }
                    console.log(list);
                    that.recordList.sort((a,b) => new Date(b.time) - new Date(a.time))
				})
			})
            }
        })
        console.log(id);

        // console.log(this.recordList);
        
    },
    data() {
        return {
            recordList: []
        }
	},
    methods: {
        itemClick(item){
            uni.getStorage({
            key:'studentId',
            success:(res) => {
            uni.navigateTo({
                url: "details?item="+JSON.stringify(item)+"&id="+res.data,
                success: res =>{console.log(res)},
                fail:err => {
                    console.log(err)
                }
			})
            }
        })
        }
    }
}
</script>

<style>

</style>